package com.esfak47.mediafetcher.app.service;

import com.google.gson.Gson;
import lombok.AllArgsConstructor;
import lombok.Getter;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Headers;
import retrofit2.http.POST;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

public interface MockupApi {
    @Headers({"Content-Type: application/json", "Accept: application/json"})
    @POST("mock/5950a2419adc231f356a6636/vue-admin/user/login")
    CompletableFuture<Map> login(@Body RequestBody userBean);

    default CompletableFuture<Map> login(UserBean userBean) {
        Gson gson = new Gson();
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), gson.toJson(userBean));
        return login(requestBody);
    }

    @AllArgsConstructor
    @Getter
    class UserBean {
        String username;
        String password;
    }

    ;
}
